
% 定义时间步长和数据
timeSteps = 0:0.05:1;

% 创建图形
figure;

plot(p.node_Coord_x,0*p.displacements(1:2:2*p.node_num),'.')

title("Case 03: simply supported-simply supported");
xlabel('X-axis');
ylabel('Y-axis');
ylim([-0.014 0]);
% GIF文件名和延迟时间
fileName = 'animationCase3.gif';
delayTime = 0.1; % 帧间隔时间

% 循环遍历每个时间步长,创建动画帧
for i = 1:length(timeSteps)
    x=p.node_Coord_x;
    y = p.displacements(1:2:2*p.node_num)*timeSteps(i);
    plot(x, y,'-','LineWidth',1); % 更新图形数据
    title("Case 03: simply supported-simply supported");
    xlabel('X-axis');
    ylabel('Y-axis');
    ylim([-0.014 0]);
    drawnow; % 刷新图形
    
    % 捕获当前帧并转换为图像
    frame = getframe(gcf);
    img = frame2im(frame);
    [A, map] = rgb2ind(img, 256);
    
    % 写入GIF文件
    if i == 1
        imwrite(A, map, fileName, 'gif', 'LoopCount', Inf, 'DelayTime', delayTime);
    else
        imwrite(A, map, fileName, 'gif', 'WriteMode', 'append', 'DelayTime', delayTime);
    end
end

% 提示动画创建成功
disp('GIF animation created successfully.');